﻿using System;
using System.Collections.Generic;


namespace advadev.DataStorage
{

    /// <summary>
    /// Must be implemented from each data storage
    /// </summary>
    public interface IDataStorage
    {

        /// <summary>
        /// When implemented, gets the application key
        /// </summary>
        string ApplicationKey
        {
            get;
        }


        /// <summary>
        /// When implemented, saves the given generic object
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <param name="genericObject">
        /// Generic object to save (must not be null and must be serializable)
        /// </param>
        void Save<T>(T genericObject) where T : IGenericObject;

        /// <summary>
        /// When implemented, saves the given list of generic object
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <param name="genericObjects">
        /// List of generic object to save (must not be null and not contain
        /// null or not serializable generic objects)
        /// </param>
        void Save<T>(IList<T> genericObjects) where T : IGenericObject;

        /// <summary>
        /// When implemented, finds the generic object with the given id and the
        /// generic object type
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <param name="id">
        /// Id of the generic object to find
        /// </param>
        /// <returns>
        /// The generic object with the given id or null
        /// </returns>
        T Find<T>(string id) where T : IGenericObject;

        /// <summary>
        /// When implemented, selects all generic objects of the generic object
        /// type
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <returns>
        /// List of generic objects
        /// </returns>
        IList<T> Select<T>() where T : IGenericObject;

        /// <summary>
        /// When implemented, deletes the given generic object
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <param name="genericObject">
        /// Generic object to delete
        /// </param>
        void Delete<T>(T genericObject) where T : IGenericObject;

        /// <summary>
        /// When implemented, deletes the given list of generic object
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        /// <param name="genericObjects">
        /// List of generic object to delete
        /// </param>
        void Delete<T>(IList<T> genericObjects) where T : IGenericObject;

        /// <summary>
        /// When implemented, deletes all generic objects of the generic object
        /// type
        /// </summary>
        /// <typeparam name="T">
        /// Generic object type
        /// </typeparam>
        void Delete<T>() where T : IGenericObject;

        /// <summary>
        /// When implemented, deletes all generic objects
        /// </summary>
        void DeleteAll();

    }

}
